package com.sskj.mine.presenter;

import com.lzy.okgo.model.Response;
import com.lzy.okrx2.adapter.FlowableBody;
import com.sskj.common.base.HttpData;
import com.sskj.lib.bean.PageBean;
import com.sskj.lib.bean.UserData;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.lib.http.JsonConverter;
import com.sskj.mine.bean.MineNoticeList;
import com.sskj.mine.bean.SysBean;
import com.sskj.mine.http.HttpConfig;
import com.sskj.mine.ui.fragment.MineFragment;

import java.util.ArrayList;
import java.util.List;

import io.reactivex.Flowable;


public class MineFragmentPresenter extends BasePresenter<MineFragment> {

    public void getNotice() {
        httpService.getGGList(null, null)
                .execute(new JsonCallBack<HttpData<PageBean<MineNoticeList>>>() {
                    @Override
                    public void onSuccess(Response<HttpData<PageBean<MineNoticeList>>> response) {
                        HttpData<PageBean<MineNoticeList>> httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.OK) {
                            if (httpData.getData() != null && httpData.getData().getList() != null) {
                                List<MineNoticeList> list = httpData.getData().getList();
                                List<MineNoticeList> listNew = new ArrayList<>();
                                switch (list.size()) {
                                    case 0:
                                        break;
                                    case 1:
                                        listNew = list.subList(0, 1);
                                        break;
                                    case 2:
                                        listNew = list.subList(0, 2);
                                        break;
                                    default:
                                        listNew = list.subList(0, 3);
                                        break;
                                }
                                mView.setNotice(listNew);
                            }
                        }
                    }
                });
    }

}